<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Admin\Model;
use Think\Model;

/**
 * 文档基础模型
 */
class MemberMessagedModel extends Model{

    public function __construct()
    {
        parent::__construct('member_messaged');
    }

    public function lists($status = 1, $order = 'uid DESC', $field = true){
        $map = array('status' => $status);
        return $this->field($field)->where($map)->order($order)->select();
    }

    //查询列表
    public function selects($condition,$field='*',$limit='')
    {
        $data_list = $this->where($condition)->field($field)->limit($limit)->select();
        return $data_list;
    }

    //查询单条
    public function info_data($condition,$field='*')
    {
        if (empty($condition)) {
            return false;
        }
        $data_list = $this->where($condition)->field($field)->find();
        return $data_list;
    }

    //添加
    public function addData($data)
    {
        if (empty($data)) {
            return false;
        }
        $datas = $this->add($data);
        return $datas;
    }

    //编辑
    public function editData($condition, $data)
    {

        if (empty($condition)) {
            return false;
        }
        $update = $this->where($condition)->save($data);
        return $update;
    }

    //删除
    public function deleteData($condition)
    {
        if (empty($condition)) {
            return false;
        }
        $dates = $this->where($condition)->delete();
        return $dates;
    }

    //统计
    public function countData($condition)
    {
        if (empty($condition)) {
            return false;
        }
        $dates = $this->where($condition)->count();
        return $dates;
    }
    //统计
    public function sumData($condition,$field)
    {
        if (empty($condition)) {
            return false;
        }
        $dates = $this->where($condition)->sum($field);
        return $dates;
    }

}
